<template>
  <!-- 基于 Element UI 新增和修改弹窗 -->
    <a-drawer
            :title="!dataForm.imgid ? '添加' : '修改'"
            :visible="visible"
            @close="cancel"
            :body-style="{ paddingBottom: '80px' }"
            :width="750"
    >
    <!-- 新增和创建表单表单 -->
    <el-form :model="dataForm" :rules="dataRule"  v-loading="loading" ref="dataForm" @keyup.enter.native="dataSubmit()" label-width="80px" style="padding: 0px 10px;margin: 0px 10px">
    <el-form-item label="创建时间" >
      <el-input v-model="dataForm.createtime" placeholder="创建时间" size="small"></el-input>
    </el-form-item>
    <el-form-item label="修改时间" >
      <el-input v-model="dataForm.modifytime" placeholder="修改时间" size="small"></el-input>
    </el-form-item>
    <el-form-item label="第三方微信唯一标识符" >
      <el-input v-model="dataForm.userwxloginkey" placeholder="第三方微信唯一标识符" size="small"></el-input>
    </el-form-item>
    <el-form-item label="第三方qq唯一标识符" >
      <el-input v-model="dataForm.userqqkey" placeholder="第三方qq唯一标识符" size="small"></el-input>
    </el-form-item>
    <el-form-item label="用户手机号" >
      <el-input v-model="dataForm.userphone" placeholder="用户手机号" size="small"></el-input>
    </el-form-item>
    <el-form-item label="手机设备Id" >
      <el-input v-model="dataForm.phonedeviceid" placeholder="手机设备Id" size="small"></el-input>
    </el-form-item>
    <el-form-item label="用户密码" >
      <el-input v-model="dataForm.userpwd" placeholder="用户密码" size="small"></el-input>
    </el-form-item>
    <el-form-item label="用户名" >
      <el-input v-model="dataForm.userniname" placeholder="用户名" size="small"></el-input>
    </el-form-item>
    <el-form-item label="用户唯一标识符" >
      <el-input v-model="dataForm.openid" placeholder="用户唯一标识符" size="small"></el-input>
    </el-form-item>
    <el-form-item label="调用接口需要用到的token" >
      <el-input v-model="dataForm.accesstoken" placeholder="调用接口需要用到的token" size="small"></el-input>
    </el-form-item>
    <el-form-item label="授权过期时间" >
      <el-input v-model="dataForm.expiredtime" placeholder="授权过期时间" size="small"></el-input>
    </el-form-item>
    <el-form-item label="用户头像" >
      <el-input v-model="dataForm.userimg" placeholder="用户头像" size="small"></el-input>
    </el-form-item>
    <el-form-item label="背景图片" >
      <el-input v-model="dataForm.bgimg" placeholder="背景图片" size="small"></el-input>
    </el-form-item>
    <el-form-item label="用户微信" >
      <el-input v-model="dataForm.userwxlogin" placeholder="用户微信" size="small"></el-input>
    </el-form-item>
    <el-form-item label="用户QQ号" >
      <el-input v-model="dataForm.userqqlogin" placeholder="用户QQ号" size="small"></el-input>
    </el-form-item>
    <el-form-item label="用户账号" >
      <el-input v-model="dataForm.usernum" placeholder="用户账号" size="small"></el-input>
    </el-form-item>
    <el-form-item label="是否推送(1不推送,2推送)" >
      <el-input v-model="dataForm.propelling" placeholder="是否推送(1不推送,2推送)" size="small"></el-input>
    </el-form-item>
    <el-form-item label="糖果数量" >
      <el-input v-model="dataForm.candynum" placeholder="糖果数量" size="small"></el-input>
    </el-form-item>
    <el-form-item label="版本更新主键" >
      <el-input v-model="dataForm.versioninfoid" placeholder="版本更新主键" size="small"></el-input>
    </el-form-item>
    <el-form-item label="启用-禁用(1-启用,2-禁用)" >
      <el-input v-model="dataForm.deleteuser" placeholder="启用-禁用(1-启用,2-禁用)" size="small"></el-input>
    </el-form-item>
    <el-form-item label="身份证表主键" >
      <el-input v-model="dataForm.identityid" placeholder="身份证表主键" size="small"></el-input>
    </el-form-item>
    <el-form-item label="邀请码" >
      <el-input v-model="dataForm.invitationcode" placeholder="邀请码" size="small"></el-input>
    </el-form-item>
    <el-form-item label="是否初次登录(1初次登录,2非初次登录)" >
      <el-input v-model="dataForm.firstlogin" placeholder="是否初次登录(1初次登录,2非初次登录)" size="small"></el-input>
    </el-form-item>
    <el-form-item label="是否修改过用户名(1否,2是)" >
      <el-input v-model="dataForm.firstupdatename" placeholder="是否修改过用户名(1否,2是)" size="small"></el-input>
    </el-form-item>
    <el-form-item label="每天的分享糖果数量" >
      <el-input v-model="dataForm.daycandynum" placeholder="每天的分享糖果数量" size="small"></el-input>
    </el-form-item>
    <el-form-item label="每日下载APP糖果数量" >
      <el-input v-model="dataForm.downloadnumy" placeholder="每日下载APP糖果数量" size="small"></el-input>
    </el-form-item>
    <el-form-item label="注册来源：1Bt商店、2Bt头条" >
      <el-input v-model="dataForm.registersource" placeholder="注册来源：1Bt商店、2Bt头条" size="small"></el-input>
    </el-form-item>
    <el-form-item label="注册系统标识：1Android、2IOS" >
      <el-input v-model="dataForm.registersystem" placeholder="注册系统标识：1Android、2IOS" size="small"></el-input>
    </el-form-item>
    <el-form-item label="登录系统标识：1Android、2IOS" >
      <el-input v-model="dataForm.loginsystem" placeholder="登录系统标识：1Android、2IOS" size="small"></el-input>
    </el-form-item>
    <el-form-item label="登录时间" >
      <el-input v-model="dataForm.logintime" placeholder="登录时间" size="small"></el-input>
    </el-form-item>
    <el-form-item label="账户更新版本号，更新即自增1" >
      <el-input v-model="dataForm.updateversion" placeholder="账户更新版本号，更新即自增1" size="small"></el-input>
    </el-form-item>
    <el-form-item label="金币冻结账户" >
      <el-input v-model="dataForm.candyfreeze" placeholder="金币冻结账户" size="small"></el-input>
    </el-form-item>
    <el-form-item label="头条每日得金币累计数量" >
      <el-input v-model="dataForm.toutiaocandyday" placeholder="头条每日得金币累计数量" size="small"></el-input>
    </el-form-item>
    <el-form-item label="身份类型：1普通用户、2企业开发者、3个人开发者" >
      <el-input v-model="dataForm.usertype" placeholder="身份类型：1普通用户、2企业开发者、3个人开发者" size="small"></el-input>
    </el-form-item>
    <el-form-item label="开发者认证状态：1未认证、已认证" >
      <el-input v-model="dataForm.developerstatus" placeholder="开发者认证状态：1未认证、已认证" size="small"></el-input>
    </el-form-item>
    <el-form-item label="用户手机IP地址" >
      <el-input v-model="dataForm.userip" placeholder="用户手机IP地址" size="small"></el-input>
    </el-form-item>
    <el-form-item label="手机mac地址" >
      <el-input v-model="dataForm.phonemac" placeholder="手机mac地址" size="small"></el-input>
    </el-form-item>
    <el-form-item label="手机品牌" >
      <el-input v-model="dataForm.phonebrand" placeholder="手机品牌" size="small"></el-input>
    </el-form-item>
    <el-form-item label="手机型号" >
      <el-input v-model="dataForm.phonemodel" placeholder="手机型号" size="small"></el-input>
    </el-form-item>
    <el-form-item label="手机系统版本代号(如20)" >
      <el-input v-model="dataForm.phonelevel" placeholder="手机系统版本代号(如20)" size="small"></el-input>
    </el-form-item>
    <el-form-item label="注册渠道来源" >
      <el-input v-model="dataForm.registerchannel" placeholder="注册渠道来源" size="small"></el-input>
    </el-form-item>
    <el-form-item label="1chat用户" >
      <el-input v-model="dataForm.btchatstatus" placeholder="1chat用户" size="small"></el-input>
    </el-form-item>
    <el-form-item label="登录位置" >
      <el-input v-model="dataForm.loginaddress" placeholder="登录位置" size="small"></el-input>
    </el-form-item>
    <el-form-item label="登录经度" >
      <el-input v-model="dataForm.longitude" placeholder="登录经度" size="small"></el-input>
    </el-form-item>
    <el-form-item label="登录纬度" >
      <el-input v-model="dataForm.latitude" placeholder="登录纬度" size="small"></el-input>
    </el-form-item>
    <el-form-item label="1男、2女" >
      <el-input v-model="dataForm.gender" placeholder="1男、2女" size="small"></el-input>
    </el-form-item>
    <el-form-item label="生日" >
      <el-input v-model="dataForm.birthday" placeholder="生日" size="small"></el-input>
    </el-form-item>
    <el-form-item label="年龄" >
      <el-input v-model="dataForm.age" placeholder="年龄" size="small"></el-input>
    </el-form-item>
    <el-form-item label="职业" >
      <el-input v-model="dataForm.occupation" placeholder="职业" size="small"></el-input>
    </el-form-item>
    <el-form-item label="个性签名" >
      <el-input v-model="dataForm.signature" placeholder="个性签名" size="small"></el-input>
    </el-form-item>
    <el-form-item label="大学生号(对应IM服务t_user表_name)" >
      <el-input v-model="dataForm.chatno" placeholder="大学生号(对应IM服务t_user表_name)" size="small"></el-input>
    </el-form-item>
    <el-form-item label="星座" >
      <el-input v-model="dataForm.xingzuo" placeholder="星座" size="small"></el-input>
    </el-form-item>
    <el-form-item label="" >
      <el-input v-model="dataForm.detailsaddr" placeholder="" size="small"></el-input>
    </el-form-item>
    <el-form-item label="800:不是vip，866:月vip，886:季vip，888:年vip，666内部使用" >
      <el-input v-model="dataForm.ifvip" placeholder="800:不是vip，866:月vip，886:季vip，888:年vip，666内部使用" size="small"></el-input>
    </el-form-item>
    <el-form-item label="会员开始时间" >
      <el-input v-model="dataForm.startvip" placeholder="会员开始时间" size="small"></el-input>
    </el-form-item>
    <el-form-item label="vip到期时间" >
      <el-input v-model="dataForm.endvip" placeholder="vip到期时间" size="small"></el-input>
    </el-form-item>
    <el-form-item label="附近的人查看次数限制" >
      <el-input v-model="dataForm.nearbycount" placeholder="附近的人查看次数限制" size="small"></el-input>
    </el-form-item>
    <el-form-item label="打招呼次数限制" >
      <el-input v-model="dataForm.greetuser" placeholder="打招呼次数限制" size="small"></el-input>
    </el-form-item>
    <el-form-item label="私聊次数统计" >
      <el-input v-model="dataForm.secret" placeholder="私聊次数统计" size="small"></el-input>
    </el-form-item>
    <el-form-item label="注册渠道" >
      <el-input v-model="dataForm.mark" placeholder="注册渠道" size="small"></el-input>
    </el-form-item>
    <el-form-item label="是否是真实用户0：真实用户，1：虚拟用户" >
      <el-input v-model="dataForm.userexist" placeholder="是否是真实用户0：真实用户，1：虚拟用户" size="small"></el-input>
    </el-form-item>
    </el-form>
        <div :style="{position: 'absolute',right: 0,bottom: 0,width: '100%', borderTop: '1px solid #e9e9e9',padding: '10px 16px',background: '#fff',textAlign: 'right',zIndex: 1,}">
            <el-button @click="cancel()" :style="{ marginRight: '8px' }">取消</el-button>
            <el-button type="primary" @click="submit()">确定</el-button>
        </div>
  </a-drawer>
</template>

<script>
    import api from '@/api/api'
    export default {
    components: {
    },
    data () {
      return {
        visible: false,
        loading:false,
        dataForm: {
          userid: 0,
          createtime: '' ,
          modifytime: '' ,
          userwxloginkey: '' ,
          userqqkey: '' ,
          userphone: '' ,
          phonedeviceid: '' ,
          userpwd: '' ,
          userniname: '' ,
          openid: '' ,
          accesstoken: '' ,
          expiredtime: '' ,
          userimg: '' ,
          bgimg: '' ,
          userwxlogin: '' ,
          userqqlogin: '' ,
          usernum: '' ,
          propelling: '' ,
          candynum: '' ,
          versioninfoid: '' ,
          deleteuser: '' ,
          identityid: '' ,
          invitationcode: '' ,
          firstlogin: '' ,
          firstupdatename: '' ,
          daycandynum: '' ,
          downloadnumy: '' ,
          registersource: '' ,
          registersystem: '' ,
          loginsystem: '' ,
          logintime: '' ,
          updateversion: '' ,
          candyfreeze: '' ,
          toutiaocandyday: '' ,
          usertype: '' ,
          developerstatus: '' ,
          userip: '' ,
          phonemac: '' ,
          phonebrand: '' ,
          phonemodel: '' ,
          phonelevel: '' ,
          registerchannel: '' ,
          btchatstatus: '' ,
          loginaddress: '' ,
          longitude: '' ,
          latitude: '' ,
          gender: '' ,
          birthday: '' ,
          age: '' ,
          occupation: '' ,
          signature: '' ,
          chatno: '' ,
          xingzuo: '' ,
          detailsaddr: '' ,
          ifvip: '' ,
          startvip: '' ,
          endvip: '' ,
          nearbycount: '' ,
          greetuser: '' ,
          secret: '' ,
          mark: '' ,
          userexist: ''
        },
        dataRule: {
          createtime: [
            { required: true, message: '创建时间  为必填项', trigger: 'blur' }
          ],
          modifytime: [
            { required: true, message: '修改时间  为必填项', trigger: 'blur' }
          ],
          userwxloginkey: [
            { required: true, message: '第三方微信唯一标识符  为必填项', trigger: 'blur' }
          ],
          userqqkey: [
            { required: true, message: '第三方qq唯一标识符  为必填项', trigger: 'blur' }
          ],
          userphone: [
            { required: true, message: '用户手机号  为必填项', trigger: 'blur' }
          ],
          phonedeviceid: [
            { required: true, message: '手机设备Id  为必填项', trigger: 'blur' }
          ],
          userpwd: [
            { required: true, message: '用户密码  为必填项', trigger: 'blur' }
          ],
          userniname: [
            { required: true, message: '用户名  为必填项', trigger: 'blur' }
          ],
          openid: [
            { required: true, message: '用户唯一标识符  为必填项', trigger: 'blur' }
          ],
          accesstoken: [
            { required: true, message: '调用接口需要用到的token  为必填项', trigger: 'blur' }
          ],
          expiredtime: [
            { required: true, message: '授权过期时间  为必填项', trigger: 'blur' }
          ],
          userimg: [
            { required: true, message: '用户头像  为必填项', trigger: 'blur' }
          ],
          bgimg: [
            { required: true, message: '背景图片  为必填项', trigger: 'blur' }
          ],
          userwxlogin: [
            { required: true, message: '用户微信  为必填项', trigger: 'blur' }
          ],
          userqqlogin: [
            { required: true, message: '用户QQ号  为必填项', trigger: 'blur' }
          ],
          usernum: [
            { required: true, message: '用户账号  为必填项', trigger: 'blur' }
          ],
          propelling: [
            { required: true, message: '是否推送(1不推送,2推送)  为必填项', trigger: 'blur' }
          ],
          candynum: [
            { required: true, message: '糖果数量  为必填项', trigger: 'blur' }
          ],
          versioninfoid: [
            { required: true, message: '版本更新主键  为必填项', trigger: 'blur' }
          ],
          deleteuser: [
            { required: true, message: '启用-禁用(1-启用,2-禁用)  为必填项', trigger: 'blur' }
          ],
          identityid: [
            { required: true, message: '身份证表主键  为必填项', trigger: 'blur' }
          ],
          invitationcode: [
            { required: true, message: '邀请码  为必填项', trigger: 'blur' }
          ],
          firstlogin: [
            { required: true, message: '是否初次登录(1初次登录,2非初次登录)  为必填项', trigger: 'blur' }
          ],
          firstupdatename: [
            { required: true, message: '是否修改过用户名(1否,2是)  为必填项', trigger: 'blur' }
          ],
          daycandynum: [
            { required: true, message: '每天的分享糖果数量  为必填项', trigger: 'blur' }
          ],
          downloadnumy: [
            { required: true, message: '每日下载APP糖果数量  为必填项', trigger: 'blur' }
          ],
          registersource: [
            { required: true, message: '注册来源：1Bt商店、2Bt头条  为必填项', trigger: 'blur' }
          ],
          registersystem: [
            { required: true, message: '注册系统标识：1Android、2IOS  为必填项', trigger: 'blur' }
          ],
          loginsystem: [
            { required: true, message: '登录系统标识：1Android、2IOS  为必填项', trigger: 'blur' }
          ],
          logintime: [
            { required: true, message: '登录时间  为必填项', trigger: 'blur' }
          ],
          updateversion: [
            { required: true, message: '账户更新版本号，更新即自增1  为必填项', trigger: 'blur' }
          ],
          candyfreeze: [
            { required: true, message: '金币冻结账户  为必填项', trigger: 'blur' }
          ],
          toutiaocandyday: [
            { required: true, message: '头条每日得金币累计数量  为必填项', trigger: 'blur' }
          ],
          usertype: [
            { required: true, message: '身份类型：1普通用户、2企业开发者、3个人开发者  为必填项', trigger: 'blur' }
          ],
          developerstatus: [
            { required: true, message: '开发者认证状态：1未认证、已认证  为必填项', trigger: 'blur' }
          ],
          userip: [
            { required: true, message: '用户手机IP地址  为必填项', trigger: 'blur' }
          ],
          phonemac: [
            { required: true, message: '手机mac地址  为必填项', trigger: 'blur' }
          ],
          phonebrand: [
            { required: true, message: '手机品牌  为必填项', trigger: 'blur' }
          ],
          phonemodel: [
            { required: true, message: '手机型号  为必填项', trigger: 'blur' }
          ],
          phonelevel: [
            { required: true, message: '手机系统版本代号(如20)  为必填项', trigger: 'blur' }
          ],
          registerchannel: [
            { required: true, message: '注册渠道来源  为必填项', trigger: 'blur' }
          ],
          btchatstatus: [
            { required: true, message: '1chat用户  为必填项', trigger: 'blur' }
          ],
          loginaddress: [
            { required: true, message: '登录位置  为必填项', trigger: 'blur' }
          ],
          longitude: [
            { required: true, message: '登录经度  为必填项', trigger: 'blur' }
          ],
          latitude: [
            { required: true, message: '登录纬度  为必填项', trigger: 'blur' }
          ],
          gender: [
            { required: true, message: '1男、2女  为必填项', trigger: 'blur' }
          ],
          birthday: [
            { required: true, message: '生日  为必填项', trigger: 'blur' }
          ],
          age: [
            { required: true, message: '年龄  为必填项', trigger: 'blur' }
          ],
          occupation: [
            { required: true, message: '职业  为必填项', trigger: 'blur' }
          ],
          signature: [
            { required: true, message: '个性签名  为必填项', trigger: 'blur' }
          ],
          chatno: [
            { required: true, message: '大学生号(对应IM服务t_user表_name)  为必填项', trigger: 'blur' }
          ],
          xingzuo: [
            { required: true, message: '星座  为必填项', trigger: 'blur' }
          ],
          detailsaddr: [
            { required: true, message: '  为必填项', trigger: 'blur' }
          ],
          ifvip: [
            { required: true, message: '800:不是vip，866:月vip，886:季vip，888:年vip，666内部使用  为必填项', trigger: 'blur' }
          ],
          startvip: [
            { required: true, message: '会员开始时间  为必填项', trigger: 'blur' }
          ],
          endvip: [
            { required: true, message: 'vip到期时间  为必填项', trigger: 'blur' }
          ],
          nearbycount: [
            { required: true, message: '附近的人查看次数限制  为必填项', trigger: 'blur' }
          ],
          greetuser: [
            { required: true, message: '打招呼次数限制  为必填项', trigger: 'blur' }
          ],
          secret: [
            { required: true, message: '私聊次数统计  为必填项', trigger: 'blur' }
          ],
          mark: [
            { required: true, message: '注册渠道  为必填项', trigger: 'blur' }
          ],
          userexist: [
            { required: true, message: '是否是真实用户0：真实用户，1：虚拟用户  为必填项', trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      init (id) { // 初始化表单验证规则
        this.dataForm.userid = id || undefined
        this.visible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.dataForm.userid){
              this.loading = true
                api.post('rest/vabc/userEntity/info',{userid:this.dataForm.userid}).then(res => {
                this.dataForm = res;
            }).finally(() => {
                this.loading = false
            });
          }
        })
      },
      // 表单数据提交
      submit () {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.loading = true
            let postData=Object.assign({},this.dataForm)
            if (!this.dataForm.userid){
                postData.userid==undefined
                api.post('rest/vabc/userEntity/save',postData).then(res =>{
                    this.$message.success("创建成功")
                    this.reset()
                    this.visible = false
                    this.$parent.getDataList()
                }).finally(() => {
                    this.loading = false
                });
            }else{
                api.post('rest/vabc/userEntity/update',postData).then(res =>{
                    this.$message.success("保存成功")
                    this.reset()
                    this.visible = false
                    this.$parent.getDataList()
                }).finally(() => {
                    this.loading = false
                });
            }
          }
        })
      },
     cancel(){
        this.visible = false
        this.reset()
    },
    reset(){
        this.$refs.dataForm.resetFields()
        this.$data.dataForm=JSON.parse(JSON.stringify(this.$options.data().dataForm))
        //图片回写
        //this.$refs["childData"].fileList=[]
    }
    }
  }
</script>
